/*
 * @Author: lin_zizhuo 2297304135@qq.com
 * @Date: 2023-11-20 07:28:41
 * @LastEditors: lin_zizhuo 2297304135@qq.com
 * @LastEditTime: 2023-11-20 15:57:03
 * @FilePath: /cpp_-linux/named_pipe/client.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE#
 */
#include "comm.hpp"

using namespace std;

int main()
{
    Log log;
    // 打开管道文件
    int fd = open(fifo_name, O_WRONLY | O_APPEND);
    if (fd == -1)
    {
        log.send_message(Fatal, "open fifo error!\n");
        exit(FIFO_OPEN_ERR);
    }
    log.send_message(Info, "client open fifo_file excuess!\n");

    // 进行通信
    while (true)
    {
        string s;
        cout << "client say @ ";
        getline(cin, s);
        write(fd, (const void *)s.c_str(), s.size());
    }
    return 0;
}